package com.madarasan.SkiDroid;

import java.util.Locale;

import android.content.Context;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;

public class MainActivity extends GlobalMenuActivity {
	
	
	
	/** Called when the activity is first created. */
	
	
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		String language = PreferenceManager.getDefaultSharedPreferences(this)
				.getString("Limba preferata", "n/a");

		updateLanguage(this, language);

		setContentView(R.layout.initiallayout);
		
		
		
		displayNotification("Pornire program");
		
		new Handler().postDelayed(new Runnable() { 
	        @Override 
	        public void run() { 
	                openOptionsMenu(); 
	        } 
	}, 500); 
       

		// ThreadPolicy tp = ThreadPolicy.LAX;
		// StrictMode.setThreadPolicy(tp); //should not be needed anymore

	}

	public static void updateLanguage(Context context, String language) {
		if (!"".equals(language)) {
			if ("ro".equals(language)) {
				language = "ro";
			} else if ("hu".equals(language)) {
				language = "hu";
			}
			Locale locale = new Locale(language);
			Locale.setDefault(locale);
			Configuration config = new Configuration();
			config.locale = locale;
			context.getResources().updateConfiguration(config, null);
		}
	}

}